package org.example.utils;

import java.sql.*;

public class ConPlsqla {



    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        String url = ReadConf.readConf("spring.datasource.url");
        String username = ReadConf.readConf("spring.datasource.username");
        String password = ReadConf.readConf("spring.datasource.password");

        Connection conn = DriverManager.getConnection(url, username, password);


            String select_sql = "select * from QCDZ_MC_SL_MCBYJL where  entname like '%帆帆帆帆建筑设计事务所（浙江）有限责任公司%'";


//        Assert.assertEquals(dwxz,"10");
//        String update_sql = "select * from QCDZ_LJM_SL_GJJBAXX \n"  + "where  pripid = \'330782020421000050303\'\n";
//        ResultSet resultSet = exec_select(update_sql);
//        String dw = null;
//        while (res.next()) {
//            dw = res.getString("dw");
//
//            System.out.println(dw);
//        }
//        Assert.assertEquals(dw,"10");



        }
        public static Connection connection() throws ClassNotFoundException, SQLException {
            String url = ReadConf.readConf("spring.datasource.url");
            String username = ReadConf.readConf("spring.datasource.username");
            String password = ReadConf.readConf("spring.datasource.password");
            Connection connection = null;
            connection = DriverManager.getConnection(url,username,password);


            System.out.println("数据更新/删除成功");
            return connection;

        }






    public static ResultSet exec_select(String sql, String entname) {
        String url = ReadConf.readConf("spring.datasource.url");
        String username = ReadConf.readConf("spring.datasource.username");
        String password = ReadConf.readConf("spring.datasource.password");
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection(url, username, password);
            pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, entname); // 设置参数
            rs = pstmt.executeQuery();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return rs;
    }
}

